package com.rs.game.player.content;

import com.rs.game.WorldObject;
import com.rs.game.player.Player;
import com.rs.utils.Utils;

public class ObjectSearch {
	
	private static int MAX_RESULTS = 250;
	
	public static void searchForObject(Player player, String objectName) {
    	int count = 0;
        for (int i = 0; i < Utils.getObjectDefinitionsSize(); i++) {
		   WorldObject object = new WorldObject(i, 0, 0, 0, 0, 0);
		   if (object.getDefinitions().getName().toLowerCase().contains(objectName.toLowerCase())) {
		    count++;
		    if (count == MAX_RESULTS) {
		     player.getPackets().sendPanelBoxMessage("<col=FF0000>Found over 50 results for " + Utils.formatPlayerNameForDisplay(objectName) + ". Only 50 listed.");
		     return;
		    }
		    player.getPackets().sendPanelBoxMessage("<col=FF0000>"+Utils.formatPlayerNameForDisplay(object.getDefinitions().getName()) + " (Id: " + object.getId()+"</col>)");
		   }
		  }
		  player.getPackets().sendPanelBoxMessage("<col=FF0000>Found " + count + " results for the object " + Utils.formatPlayerNameForDisplay(objectName) + ".");
		 }
}